
myApp.controller('userCouponListController',function($scope,toaster,$serCoupon){
    var ctrl = this;
    ctrl.vm = {
        data:{},
        search:{
            u_id:'',
            coupon_id:'',
            status:'',
        },
        changeTimeS:function(){
            ctrl.vm.search.startStamp = Date.parse(ctrl.vm.search.startTime);
            ctrl.vm.search.endStamp = Date.parse(ctrl.vm.search.endTime);
        },
        changeTimeE:function(){
            ctrl.vm.search.startStamp = Date.parse(ctrl.vm.search.startTime);
            ctrl.vm.search.endStamp = Date.parse(ctrl.vm.search.endTime);
        },
        searchFn:function(){
            vm.init();
        },
        reset:function(){
            ctrl.vm.search.u_id='';
            ctrl.vm.search.coupon_id='';
            ctrl.vm.search.status='';
            vm.init();
        }
    };
    $scope.vm={
        page:{}
    };
    /*跳转页面*/
    $scope.pageChanged = function() {
        vm.init($scope.vm.page.current_page)
    };
    /*每页显示数量显示*/
    $scope.placement = {
        options: [5,10,20,50],
        pageSize:5,
        selected: 20,
        changeFn:function(){
            vm.init(0)
        }
    };
    var vm ={
        init:function(page){
            $serCoupon.getUserCouponList({
                page:page||1,
                size:$scope.placement.selected,
                coupon_id:ctrl.vm.search.coupon_id||'',
                u_id:ctrl.vm.search.u_id||'',
                status:ctrl.vm.search.status||'',
            }).then(function(res){
                if(res.code==1){
                    ctrl.vm.data = res.data;
                    $scope.vm.page = res.addtion_data;
                }else{
                    ctrl.vm.data ="";
                    toaster.info('提示',res.message);
                }
            })
        }
    };
    vm.init();
});

